const URL =
  {
    //http://novel-1252720877.file.myqcloud.com/public资源接口
    books:"https://novel-1252720877.file.myqcloud.com/h5",
    querylei: "https://novel.88youxi.cn/api/public/querylei",//书籍类型
    querybook: "https://novel.88youxi.cn/api/public/querybook",//书籍接口
    insertuser: "https://novel.88youxi.cn/api/public/insertuser",//用户注册接口
    updateread: "https://novel.88youxi.cn/api/public/updateread",//阅读上传接口
    updatezan: "https://novel.88youxi.cn/api/public/updatezan",//点赞上传接口
    cancelzan: "https://novel.88youxi.cn/api/public/cancelzan",//取消点赞接口
    updatestore:"https://novel.88youxi.cn/api/public/updatestore",  //收藏接口
    cancelstore: "https://novel.88youxi.cn/api/public/cancelstore",     //取消收藏接口
    querybookById: "https://novel.88youxi.cn/api/public/querybookById",    //通过书籍id查询书籍信息接口
    addHistory:"https://novel.88youxi.cn/api/public/addHistory",        //阅读历史上传接口
    queryUserBook:"https://novel.88youxi.cn/api/public/queryUserBook" ,                                                 //查询书籍进度信息
    queryBookInfo:"https://novel.88youxi.cn/api/public/queryBookInfo",                                                //查询书籍信息和进度信息
    updateProcess:"https://novel.88youxi.cn/api/public/updateProcess",                                             //上传进度接
    queryHistory:"https://novel.88youxi.cn/api/public/queryHistory",                                             //查询阅读历史列表
                                                      
    queryStore: "https://novel.88youxi.cn/api/public/queryStore",//查询收藏列表
    queryBuy:"https://novel.88youxi.cn/api/public/queryBuy",  //查询购买信息
    updateBuy: "https://novel.88youxi.cn/api/public/updateBuy",  //上传购买信息                                     
    queryUserInfo: "https://novel.88youxi.cn/api/public/queryUserInfo",   //个人页查询历史总数和收藏总数接口                                           
                                                     


  }



function _geturl(url, success, fail) {

  console.log("------start---_get----");
  wx.request({
    url: url,
    header: {
       'Content-Type': 'application/json'
    },
    success: function (res) {
      success(res);
    },
    fail: function (res) {
      fail(res);
    }
  });
  console.log("----end-----_get----");
}

function _getdata(url, data, success) {
  wx.request({
    url: url,
    data: data,
    success: function (res) {
      success(res);
    },
    fail: function (err) {
      console.log("失败了---" + err);
    }

  })

}
/**
 * url 请求地址
 * success 成功的回调
 * fail 失败的回调
 */
function post_from(url, data, success, fail) {
  console.log("----_post--start-------");
  wx.request({
    url: url,
    header: {
      'content-type': 'application/x-www-form-urlencoded',
    },
    method: 'POST',
    data: data,
    success: function (res) {
      // console.log("----_post成功--");
      success(res);
    },
    fail: function (res) {
      console.log("----_post-失败-------");
      fail(res);
    }
  });
  console.log("----end-----_get----");
}

/**
* url 请求地址
* success 成功的回调
* fail 失败的回调
*/
function post_json(url, data, success, fail) {
  console.log("----_post--start-------");
  wx.request({
    url: url,
    header: {
      'content-type': 'application/json',
    },
    data: data,
    method: 'POST',
    success: function (res) {
      success(res);
    },
    fail: function (res) {
      fail(res);
    }
  });
  console.log("----end----_post-----");
}


module.exports = {

  URL: URL,
  _geturl: _geturl,
  post_from: post_from,
  _getdata: _getdata,
  post_json: post_json
}




